#include "ShaderEffect.h"

ShaderEffect::ShaderEffect()
{
	effectName = NULL;
	uniformNames = NULL;
	effectId = 0;
	vertexSource = NULL;
	fragmentSource = NULL;
	uniformsId = NULL;
};

ShaderEffect::~ShaderEffect()
{
	FreeCacheData();
	SAFE_DEL_ARRAY(effectName); 
	SAFE_DEL_ARRAY(uniformsId);
};

int ShaderEffect::operator[](const int uniformIndex)
{
	return uniformsId[uniformIndex];
};

void ShaderEffect::FreeCacheData()
{
	SAFE_DEL_ARRAY(vertexSource);
	SAFE_DEL_ARRAY(fragmentSource);

	if(!uniformNames) {
		return;
	}
	pchar *p = uniformNames; 
	while (*p) {
		SAFE_DEL(*p);
		p++;
	}

	SAFE_DEL_ARRAY(uniformNames);
};
